package org.example;

import dev.langchain4j.model.openai.OpenAiChatModel;

public class Main {
    public static void main(String[] args) {
        //2.构建OpenAiChatModel对象
        OpenAiChatModel openAiChatModel = OpenAiChatModel.builder()
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .apiKey(System.getenv("API-KEY"))
                .modelName("qwen-plus")
                .logRequests(true)//设置打印请求日志
                .logResponses(true)//设置打印响应日志
                .build();

        //3.调用chat方法,交互
        String result = openAiChatModel.chat("你是谁?");
        System.out.println(result);
    }
}